﻿/*
 * Author: Brian Brewder
 * Website: http://redwerb.com
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using Microsoft.VisualStudio.DebuggerVisualizers;
using System.Drawing;

//Visualizers don't support inheritance so only the following exceptions are supported.
[assembly: DebuggerVisualizer(typeof(Redwerb.Visualizers.ExceptionVisualizer.ExceptionVisualizer), typeof(VisualizerObjectSource), Target = typeof(System.Exception), Description = "Exception Visualizer")]
[assembly: DebuggerVisualizer(typeof(Redwerb.Visualizers.ExceptionVisualizer.ExceptionVisualizer), typeof(VisualizerObjectSource), Target = typeof(System.ApplicationException), Description = "Exception Visualizer")]

namespace Redwerb.Visualizers.ExceptionVisualizer
{
    
    public class ExceptionVisualizer
        : DialogDebuggerVisualizer
    {
        protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
        {
            var ex = objectProvider.GetObject() as Exception;
            if (ex == null) return;
            var dlg = new ExceptionVisualizerDialog();
            dlg.Exception = ex;
            dlg.ShowDialog();
        }
    }
}
